package com.example.xiaoweiassistant;

import android.graphics.Color;
import android.util.Log;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;

/*
createName : 程序员keven
createTime : 2022/4/5
*/
public  class util {

    public static void startRequest(String key , int value , String root){
        new Thread(new Runnable() {
            @Override
            public void run() {
                OkHttpClient okHttpClient = new OkHttpClient();
                Request.Builder builder = new Request.Builder()
                        .url("http:192.168.4.1/"+root+"?"+key+"="+value)
                        .get();
                Request request = builder.build();
                Call call = okHttpClient.newCall(request);
                try {
                    String string = call.execute().body().string();
                    Log.e("t" , string);
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }).start();
    }

    public static int[] hexToRGB(int colorValue){
        int[] hsv = new int[3];
//        int color = Integer.parseInt(String.valueOf(colorValue), 16);

        int b = colorValue & 0xff;

        int g = (colorValue >> 8) & 0xff;

        int r = (colorValue >> 16) & 0xff;

        hsv[0] = r ;
        hsv[1] = g  ;
        hsv[2] = b ;

        return  hsv  ;
    }

    public static String intToHex(int n) {
        StringBuffer s = new StringBuffer();
        String a;
        char []b = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
        while(n != 0){
            s = s.append(b[n%16]);
            n = n/16;
        }
        a = s.reverse().toString();
        return a;
    }
}
